<template>
  <div
    class="time-container"
    :class="{
      'time-border-show': props.isShowBorder && !configStore.config.isDark,
      'time-border-show-dark': props.isShowBorder && configStore.config.isDark,
      'time-container-border': !configStore.config.isDark,
      'time-container-border-dark': configStore.config.isDark
    }"
  >
    <div class="time-display">
      <div class="time-left">
        <slot name="time-left" />
      </div>
      <div class="time-box">
        <slot name="time-box" />
      </div>
      <div class="time-right">
        <slot name="time-right" />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
// 表盘
import windowMoveEvent from '@renderer/composables/windowMoveEvent'
import { useConfigStore } from '@renderer/stores/configStore'
import { onMounted } from 'vue'

const configStore = useConfigStore()

const props = defineProps<{
  isShowBorder?: boolean
}>()

onMounted(() => {
  const { setMouseMoveEvent } = windowMoveEvent()
  setMouseMoveEvent('.time-container')
})
</script>

<style lang="scss" scoped>
@mixin borderShow() {
  .time-display {
    border: 1px dashed rgba(255, 255, 255, 0.2);
    opacity: 1;

    .time-left,
    .time-right {
      // 展示
      opacity: 1;
    }
  }
}

@mixin darkBorderShow() {
  .time-display {
    border: 1px dashed rgba(0, 0, 0, 0.2);
    opacity: 1;

    .time-left,
    .time-right {
      // 展示
      opacity: 1;
    }
  }
}

.time-container-border {
  &:hover {
    @include borderShow();
  }
}

.time-container-border-dark {
  &:hover {
    @include darkBorderShow();
  }
}

.time-container {
  width: 160px;
  height: 60px;
  position: relative;
  box-sizing: border-box;
  padding: 2px;
  border-radius: 16px;

  .time-display {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    transition: background-color 0.3s;
    opacity: 1;
    border-radius: 14px;
    border: 1px dashed rgba(255, 255, 255, 0);

    .time-left,
    .time-right {
      height: 100%;
      width: 25px;
      // background-color: red;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      gap: 2px;
      opacity: 0;
    }

    .time-left {
      align-items: flex-end;
    }

    .time-right {
      align-items: flex-start;
    }

    .time-box {
      height: 100%;
      width: auto;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }
  }
}

.time-border-show {
  @include borderShow();
}

.time-border-show-dark {
  @include darkBorderShow();
}
</style>
